//
//  MeetingManager.m
//  Rongcloud
//
//  Created by LiuLinhong on 2018/04/18.
//  Copyright © 2018年 Beijing Rongcloud Network Technology Co. , Ltd. All rights reserved.
//

#import "MeetingManager.h"

static MeetingManager *sharedMeetingManager = nil;


@interface MeetingManager ()

@property (nonatomic, assign) BOOL isSwitchVideoView, isCloseCamera;
@property (nonatomic, assign) BOOL is0RequestSpeak, is1Invite, is2ManageMeeting, is3UseWhiteBoard, is4ShareScreen, is5Speaker, is7Mute;
@property (nonatomic, assign) BOOL isCallingBreath, isWhiteBoardExist, isHideControlView, isFullScreen, isDataInfoOpen;
@property (nonatomic, assign) NSInteger observerIndex, closeCameraIndex;
@property (nonatomic, assign) NSInteger selectedSwitchCellIndex, selectedSwitchPageIndex;
@property (nonatomic, strong) NSMutableArray *handupRequestArray, *promoteCapacityArray;
@property (nonatomic, strong) NSMutableArray *localDataInfoArray, *memberDataInfoArray, *userIDArray, *upgradeUserIDArray;
@property (nonatomic, strong) NSMutableArray *remoteVideoViewArray, *remoteAllMemberArray;

@end


@implementation MeetingManager

@synthesize isSwitchVideoView = _isSwitchVideoView;
@synthesize isCloseCamera = _isCloseCamera;
@synthesize is0RequestSpeak = _is0RequestSpeak;
@synthesize is1Invite = _is1Invite;
@synthesize is2ManageMeeting = _is2ManageMeeting;
@synthesize is3UseWhiteBoard = _is3UseWhiteBoard;
@synthesize is4ShareScreen = _is4ShareScreen;
@synthesize is5Speaker = _is5Speaker;
@synthesize is7Mute = _is7Mute;
@synthesize isCallingBreath = _isCallingBreath;
@synthesize isWhiteBoardExist = _isWhiteBoardExist;
@synthesize isHideControlView = _isHideControlView;
@synthesize isFullScreen = _isFullScreen;
@synthesize isDataInfoOpen = _isDataInfoOpen;
@synthesize observerIndex = _observerIndex;
@synthesize closeCameraIndex = _closeCameraIndex;
@synthesize selectedSwitchCellIndex = _selectedSwitchCellIndex;
@synthesize selectedSwitchPageIndex = _selectedSwitchPageIndex;

+ (instancetype)sharedManager
{
    static dispatch_once_t once_dispatch;
    dispatch_once(&once_dispatch, ^{
        sharedMeetingManager = [[MeetingManager alloc] init];
    });
    return sharedMeetingManager;
}


#pragma mark - isSwitchVideoView
- (BOOL)isSwitchVideoView
{
    return _isSwitchVideoView;
}

- (void)setIsSwitchVideoView:(BOOL)is
{
    _isSwitchVideoView = is;
}

#pragma mark - isCloseCamera
- (BOOL)isCloseCamera
{
    return _isCloseCamera;
}

- (void)setIsCloseCamera:(BOOL)is
{
    _isCloseCamera = is;
}

#pragma mark - is0RequestSpeak
- (BOOL)is0RequestSpeak
{
    return _is0RequestSpeak;
}

- (void)setIs0RequestSpeak:(BOOL)is
{
    _is0RequestSpeak = is;
}

#pragma mark - is1Invite
- (BOOL)is1Invite
{
    return _is1Invite;
}

- (void)setIs1Invite:(BOOL)is
{
    _is1Invite = is;
}

#pragma mark - is2ManageMeeting
- (BOOL)is2ManageMeeting
{
    return _is2ManageMeeting;
}

- (void)setIs2ManageMeeting:(BOOL)is
{
    _is2ManageMeeting = is;
}

#pragma mark - is3UseWhiteBoard
- (BOOL)is3UseWhiteBoard
{
    return _is3UseWhiteBoard;
}

- (void)setIs3UseWhiteBoard:(BOOL)is
{
    _is3UseWhiteBoard = is;
}

#pragma mark - is4ShareScreen
- (BOOL)is4ShareScreen
{
    return _is4ShareScreen;
}

- (void)setIs4ShareScreen:(BOOL)is
{
    _is4ShareScreen = is;
}

#pragma mark - is5Speaker
- (BOOL)is5Speaker
{
    return _is5Speaker;
}

- (void)setIs5Speaker:(BOOL)is
{
    _is5Speaker = is;
}

#pragma mark - is7Mute
- (BOOL)is7Mute
{
    return _is7Mute;
}

- (void)setIs7Mute:(BOOL)is
{
    _is7Mute = is;
}

#pragma mark - isCallingBreath
- (BOOL)isCallingBreath
{
    return _isCallingBreath;
}

- (void)setIsCallingBreath:(BOOL)is
{
    _isCallingBreath = is;
}

#pragma mark - isWhiteBoardExist
- (BOOL)isWhiteBoardExist
{
    return _isWhiteBoardExist;
}

- (void)setIsWhiteBoardExist:(BOOL)is
{
    _isWhiteBoardExist = is;
}

#pragma mark - isHideControlView
- (BOOL)isHideControlView
{
    return _isHideControlView;
}

- (void)setIsHideControlView:(BOOL)is
{
    _isHideControlView = is;
}

#pragma mark - isFullScreen
- (BOOL)isFullScreen
{
    return _isFullScreen;
}

- (void)setIsFullScreen:(BOOL)is
{
    _isFullScreen = is;
}

#pragma mark - isDataInfoOpen
- (BOOL)isDataInfoOpen
{
    return _isDataInfoOpen;
}

- (void)setIsDataInfoOpen:(BOOL)is
{
    _isDataInfoOpen = is;
}

#pragma mark - observerIndex
- (NSInteger)observerIndex
{
    return _observerIndex;
}

- (void)setObserverIndex:(NSInteger)index
{
    _observerIndex = index;
}

#pragma mark - closeCameraIndex
- (NSInteger)closeCameraIndex
{
    return _closeCameraIndex;
}

- (void)setCloseCameraIndex:(NSInteger)index
{
    _closeCameraIndex = index;
}

#pragma mark - selectedSwitchCellIndex
- (NSInteger)selectedSwitchCellIndex
{
    return _selectedSwitchCellIndex;
}

- (void)setSelectedSwitchCellIndex:(NSInteger)index
{
    _selectedSwitchCellIndex = index;
}

#pragma mark - selectedSwitchPageIndex
- (NSInteger)selectedSwitchPageIndex
{
    return _selectedSwitchPageIndex;
}

- (void)setSelectedSwitchPageIndex:(NSInteger)index
{
    _selectedSwitchPageIndex = index;
}

#pragma mark - handupRequestArray
- (NSMutableArray *)handupRequestArray
{
    if (!_handupRequestArray)
        _handupRequestArray = [NSMutableArray array];
    
    return _handupRequestArray;
}

- (void)addHandupRequestArrayObject:(id)object
{
    if (object)
        [self.handupRequestArray addObject:object];
}

- (void)removeHandupRequestArrayObject:(id)object
{
    if (object)
        [self.handupRequestArray removeObject:object];
}

- (BOOL)isHandupRequestArrayContainObject:(id)object
{
    if (object)
        return [self.handupRequestArray containsObject:object];
    else
        return NO;
}

#pragma mark - promoteCapacityArray
- (NSMutableArray *)promoteCapacityArray
{
    if (!_promoteCapacityArray)
        _promoteCapacityArray = [NSMutableArray array];
    
    return _promoteCapacityArray;
}

- (void)addPromoteCapacityArrayObject:(id)object
{
    if (object)
        [self.promoteCapacityArray addObject:object];
}

- (void)removePromoteCapacityArrayObject:(id)object
{
    if (object)
        [self.promoteCapacityArray removeObject:object];
}

- (BOOL)isPromoteCapacityArrayContainObject:(id)object
{
    if (object)
        return [self.promoteCapacityArray containsObject:object];
    else
        return NO;
}

#pragma mark - localDataInfoArray
- (NSMutableArray *)localDataInfoArray
{
    if (!_localDataInfoArray)
        _localDataInfoArray = [NSMutableArray array];
    return _localDataInfoArray;
}

- (void)addLocalDataInfoArrayObject:(id)object
{
    if (object)
        [self.localDataInfoArray addObject:object];
}

- (void)removeLocalDataInfoArrayAllObject
{
    [self.localDataInfoArray removeAllObjects];
}

#pragma mark - memberDataInfoArray
- (NSMutableArray *)memberDataInfoArray
{
    if (!_memberDataInfoArray)
        _memberDataInfoArray = [NSMutableArray array];
    return _memberDataInfoArray;
}

- (void)addMemberDataInfoArrayObject:(id)object
{
    if (object)
        [self.memberDataInfoArray addObject:object];
}

- (void)removeMemberDataInfoArrayAllObject
{
    [self.memberDataInfoArray removeAllObjects];
}

#pragma mark - upgradeUserIDArray
- (NSMutableArray *)upgradeUserIDArray
{
    if (!_upgradeUserIDArray)
        _upgradeUserIDArray = [NSMutableArray array];
    return _upgradeUserIDArray;
}

- (void)addUpgradeUserIDArrayObject:(id)object
{
    if (object)
        [self.upgradeUserIDArray addObject:object];
}

- (void)removeUpgradeUserIDArrayObject:(id)object
{
    if (object)
        [self.upgradeUserIDArray removeObject:object];
}

- (void)removeUpgradeUserIDArrayAllObject
{
    [self.upgradeUserIDArray removeAllObjects];
}

- (BOOL)isUpgradeUserIDArrayContainObject:(id)object
{
    if (object)
        return [self.upgradeUserIDArray containsObject:object];
    else
        return NO;
}

#pragma mark - userIDArray
- (NSMutableArray *)userIDArray
{
    if (!_userIDArray)
        _userIDArray = [NSMutableArray array];
    return _userIDArray;
}

- (void)addUserIDArrayObject:(id)object
{
    if (object)
        [self.userIDArray addObject:object];
}

- (void)removeUserIDArrayObject:(id)object
{
    if (object)
        [self.userIDArray removeObject:object];
}

- (void)removeObjectFromUserIDArrayAtIndex:(NSUInteger)index
{
    if (index < [self.userIDArray count])
        [self.userIDArray removeObjectAtIndex:index];
}

- (void)removeUserIDArrayAllObject
{
    [self.userIDArray removeAllObjects];
}

- (BOOL)isUserIDArrayContainObject:(id)object
{
    if (object)
        return [self.userIDArray containsObject:object];
    else
        return NO;
}

#pragma mark - remoteAllMemberArray
- (NSMutableArray *)remoteAllMemberArray
{
    if (!_remoteAllMemberArray)
        _remoteAllMemberArray = [NSMutableArray array];
    return _remoteAllMemberArray;
}

- (void)addRemoteAllMemberArrayObject:(id)object
{
    if (object)
        [self.remoteAllMemberArray addObject:object];
}

- (void)removeRemoteAllMemberArrayObject:(id)object
{
    if (object)
        [self.remoteAllMemberArray removeObject:object];
}

- (void)removeObjectFromRemoteAllMemberArrayAtIndex:(NSUInteger)index
{
    if (index < [self.remoteAllMemberArray count])
        [self.remoteAllMemberArray removeObjectAtIndex:index];
}

- (void)removeRemoteAllMemberArrayAllObject
{
    [self.remoteAllMemberArray removeAllObjects];
}

- (BOOL)isRemoteAllMemberArrayContainObject:(id)object
{
    if (object)
        return [self.remoteAllMemberArray containsObject:object];
    else
        return NO;
}

- (MeetingVideoViewModel *)getRemoteAllMemberArrayObject:(NSString *)userID
{
    MeetingVideoViewModel *model = nil;
    for (MeetingVideoViewModel *tmpModel in self.remoteAllMemberArray)
    {
        if ([tmpModel.userID isEqualToString:userID])
        {
            model = tmpModel;
            return model;
        }
    }
    return model;
}

- (NSString *)getUserNameFromRemoteAllMemberArray:(NSString *)userID
{
    MeetingVideoViewModel *model = [self getRemoteAllMemberArrayObject:userID];
    if (model && model.userName)
        return model.userName;
    else
        return @"";
}

- (NSInteger)indexOfRemoteAllMemberArrayObject:(id)object
{
    return [self.remoteAllMemberArray indexOfObject:object];
}

- (void)replaceObjectInRemoteAllMemberArrayAtIndex:(NSUInteger)index withObject:(id)object
{
    [self.remoteAllMemberArray replaceObjectAtIndex:index withObject:object];
}

#pragma mark - remoteVideoViewArray
- (NSMutableArray *)remoteVideoViewArray
{
    if (!_remoteVideoViewArray)
        _remoteVideoViewArray = [NSMutableArray array];
    return _remoteVideoViewArray;
}

- (void)addRemoteVideoViewArrayObject:(id)object
{
    if (object)
        [self.remoteVideoViewArray addObject:object];
}

- (void)removeRemoteVideoViewArrayObject:(id)object
{
    if (object)
        [self.remoteVideoViewArray removeObject:object];
}

- (void)removeObjectFromRemoteVideoViewArrayAtIndex:(NSUInteger)index
{
    if (index < [self.remoteVideoViewArray count])
        [self.remoteVideoViewArray removeObjectAtIndex:index];
}

- (void)removeObjectFromRemoteVideoViewArrayWithUserID:(NSString *)userID
{
    MeetingVideoViewModel *model = [self getRemoteVideoViewArrayObject:userID];
    if (model)
        [self.remoteVideoViewArray removeObject:model];
}

- (void)removeRemoteVideoViewArrayAllObject
{
    [self.remoteVideoViewArray removeAllObjects];
}

- (BOOL)isRemoteVideoViewArrayContainObject:(id)object
{
    if (object)
        return [self.remoteVideoViewArray containsObject:object];
    else
        return NO;
}

- (MeetingVideoViewModel *)getRemoteVideoViewArrayObject:(NSString *)userID
{
    MeetingVideoViewModel *model = nil;
    for (MeetingVideoViewModel *tmpModel in self.remoteVideoViewArray)
    {
        if ([tmpModel.userID isEqualToString:userID])
        {
            model = tmpModel;
            return model;
        }
    }
    return model;
}

- (NSInteger)indexOfRemoteVideoViewArrayObject:(id)object
{
    return [self.remoteVideoViewArray indexOfObject:object];
}

- (NSInteger)indexOfRemoteVideoViewArrayUser:(id)userId
{
    NSInteger index = -1;
    for (NSInteger i = 0; i < [self.remoteVideoViewArray count]; i++)
    {
        MeetingVideoViewModel *model = (MeetingVideoViewModel *)self.remoteVideoViewArray[i];
        if ([model.userID isEqualToString:userId])
        {
            index = i;
            break;
        }
    }
    return index;
}

- (void)replaceObjectInRemoteVideoViewArrayAtIndex:(NSUInteger)index withObject:(id)object
{
    [self.remoteVideoViewArray replaceObjectAtIndex:index withObject:object];
}


@end
